package com.example.demo.servlet;

import com.example.demo.dao.UserDao;
import com.example.demo.entity.UserVo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/findpassword")

public class Findpassword extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username = req.getParameter("username");
        String telephone = req.getParameter("telephone");
        String password = req.getParameter("password");
        String repassword = req.getParameter("repassword");
        UserVo userVo = new UserVo();
        try {
            if (userVo!=null&&userVo.getTelephone().equals(telephone)&&userVo.getUserName().equals(username)) {
                userVo.setUserName(username);
                userVo.setPassword(password);
                userVo.setTelephone(telephone);
                new UserDao().updateUser(userVo);
                req.getRequestDispatcher("/login.jsp").forward(req,resp);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
